package com.ruoyi.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.wms.domain.EndLifeVehicleExtend;
import com.ruoyi.wms.service.IEndLifeVehicleExtendService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 报废车辆扩展信息Controller
 *
 * @author ruoyi
 * @date 2025-10-31
 */
@Api(value = "报废车辆扩展信息Controller", tags = "报废车辆扩展信息Controller  ")

@RestController
@RequestMapping("/extend")
public class EndLifeVehicleExtendController extends BaseController {
    @Autowired
    private IEndLifeVehicleExtendService endLifeVehicleExtendService;

    /**
     * 查询报废车辆扩展信息列表
     */
    @RequiresPermissions("wms:extend:list")
    @GetMapping("/list")
    public TableDataInfo list(EndLifeVehicleExtend endLifeVehicleExtend) {
        startPage();
        List<EndLifeVehicleExtend> list = endLifeVehicleExtendService.selectEndLifeVehicleExtendList(endLifeVehicleExtend);
        return getDataTable(list);
    }

    /**
     * 获取报废车辆扩展信息详细信息
     */
/*    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(endLifeVehicleExtendService.selectEndLifeVehicleExtendById(id));
    }*/


    @ApiOperation("获取司机信息详细信息息getInfoById或者车牌号码")
    @GetMapping(value = "/getExtendInfoByPlateNo")
    public AjaxResult getExtendInfoByPlateNo(@ApiParam(value = "车牌号码", required = true) @RequestParam(value = "plateNo") String plateNo) {
        return success(endLifeVehicleExtendService.selectEndLifeVehicleExtendById(plateNo));
    }



    /**
     * 修改报废车辆扩展信息
     */
    @RequiresPermissions("wms:extend:edit")
    @Log(title = "报废车辆扩展信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EndLifeVehicleExtend endLifeVehicleExtend) {
        return toAjax(endLifeVehicleExtendService.updateEndLifeVehicleExtend(endLifeVehicleExtend));
    }

    /**
     * 删除报废车辆扩展信息
     */


    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody String[] ids) {
        if (ids == null || ids.length == 0) {
            return error("未选中");
        }
        int i = endLifeVehicleExtendService.deleteEndLifeVehicleExtendByIds(ids);
        if (i > 0) {
            return success("删除成功");
        }
        return toAjax(i);
    }

}
